package p2p.view.components.bases
{
	import mx.containers.Canvas;
	import mx.controls.ComboBox;
	import mx.controls.TextInput;
	import mx.utils.StringUtil;
	
	import p2p.controller.events.LoginEvent;
	import p2p.model.vo.LoginVO;
	
	[Event(name="loginEvent", type="p2p.controller.events.LoginEvent")]
	public class LoginPageBase extends Canvas
	{
		[Bindable]
		public var userNameTI:TextInput;
		[Bindable]
		public var userGroupCB:ComboBox;
		
		[Bindable]
		protected var GROUPS_DP:Array = [
			{id:'__group_flex', label:'Adobe Flex'},
			{id:'__group_java', label:'J2SE/J2EE'},
			{id:'__group_c', label:'C++'}
		];
		
		public function LoginPageBase()
		{
			super();
		}
		
		protected function enter() : void
		{
			var userName:String = StringUtil.trim(userNameTI.text);
			var userGroup:Object = userGroupCB.selectedItem;
			
			dispatchEvent(new LoginEvent(new LoginVO(true, userName, userGroup)));
		}
	}
}